package cn.bdqn.controller;

import cn.bdqn.service.RptService;
import cn.bdqn.vo.ConsRptVo;
import cn.bdqn.vo.ContrRptVo;
import cn.bdqn.vo.SvrRptVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class RptController {
    @Resource
    RptService rptService;
/**
 * 客户贡献分析
 * @param custName
 * @param pageIndex
 * @param model
 * @return
 */
@RequestMapping("/contrRpt/list")
public String list(String custName,
                   @RequestParam(defaultValue = "1") Integer pageIndex,
                   Model model){
        //设置每页显示条数
    int pageSize=3;
        //查询每页显示的数据
    IPage<ContrRptVo> contrRptVoPage =
            rptService.getContrRptVosByPage(custName,pageIndex,pageSize);
    model.addAttribute("contrRptVoPage",contrRptVoPage);
        //查询条件 回显
    model.addAttribute("custName",custName);
    return "rpt/contr_list";
}
    /**
     * 客户贡献分析
     * @return
     */
    @RequestMapping("/contrRpt/getContrRpt")
    @ResponseBody
    public Object getContrRpt(){
        return rptService.getContrRptVos();
    }

    /**
     * 客户构成分析
     * @param pageIndex
     * @param model
     * @return
     */
    @RequestMapping("/consRpt/list")
    public String consRptList(@RequestParam(defaultValue = "1") Integer pageIndex,
                              Model model){
        //设置每页显示条数
        int pageSize=3;
        //查询每页显示的数据
        IPage<ConsRptVo> consRptVoPage=
                rptService.getConsRptVosByPage("客户等级",pageIndex,pageSize);
        System.out.println(consRptVoPage);
        model.addAttribute("consRptVoPage",consRptVoPage);
        return "rpt/cons_list";
    }
    /**
     * 客户构成分析
     * @return
     */
    @RequestMapping("/consRpt/getConsRpt")
    @ResponseBody
    public Object getConsRpt(){
        return rptService.getConsRptVos("客户等级");
    }

    /**
     * 客户服务分析
     * @param pageIndex
     * @param model
     * @return
     */
    @RequestMapping("/svrRpt/list")
    public String svrRptList(@RequestParam(defaultValue = "1") Integer pageIndex,
                             Model model){
        //设置每页显示条数
        int pageSize=3;
        //查询每页显示的数据
        IPage<SvrRptVo> svrRptVoPage=
                rptService.getSvrRptVosByPage("服务类型",pageIndex,pageSize);
        model.addAttribute("svrRptVoPage",svrRptVoPage);
        return "rpt/svr_list";
    }
    /**
     * 客户服务分析
     * @return
     */
    @RequestMapping("/svrRpt/getSvrRpt")
    @ResponseBody
    public Object getSvrRpt(){
        return rptService.getSvrRptVos("服务类型");
    }
}

